﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolCode.Web; 

namespace CoolCode.Web.UI
{
    public static class BinderExtensions
    {     
        #region Model Binder

        public static void UpdateModel<T>(this Control container, T TModel) where T : class
        {
            UpdateModel<T>(container, TModel, null);
        }

        public static void UpdateModel<T>(this Control container, T TModel, string[] includeProperties) where T : class
        {
            Controller controller = new Controller();
            controller.ValueProvider = new PrefixableValueProvider(controller.ControllerContext, PrefixType.Camel  );
            controller.TryUpdateModel(TModel, includeProperties  );
        }        
       #endregion 
    }
}
